using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class PSPaymentMap : EntityTypeConfiguration<PSPayment>
    {
        public PSPaymentMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.PAYNUMBER)
                .HasMaxLength(20);

            this.Property(t => t.CCEXPDATE)
                .HasMaxLength(4);

            this.Property(t => t.CASHACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.CUSTID)
                .HasMaxLength(6);

            this.Property(t => t.vglbatch)
                .HasMaxLength(10);

            this.Property(t => t.vendid)
                .HasMaxLength(6);

            this.Property(t => t.origin)
                .HasMaxLength(10);

            this.Property(t => t.CCNAME)
                .HasMaxLength(50);

            this.Property(t => t.PVRV)
                .HasMaxLength(10);

            this.Property(t => t.Note1)
                .HasMaxLength(100);

            this.Property(t => t.Note2)
                .HasMaxLength(100);

            this.Property(t => t.PaId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.DBCRACCT)
                .HasMaxLength(40);

            this.Property(t => t.OldPVRV)
                .HasMaxLength(10);

            this.Property(t => t.PSP_Physician)
                .HasMaxLength(6);

            this.Property(t => t.PSP_VoucherPrefix)
                .HasMaxLength(5);

            // Table & Column Mappings
            this.ToTable("PSPayment");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.PSID).HasColumnName("PSID");
            this.Property(t => t.AMOUNT).HasColumnName("AMOUNT");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.PAYTYPE).HasColumnName("PAYTYPE");
            this.Property(t => t.PAYNUMBER).HasColumnName("PAYNUMBER");
            this.Property(t => t.CCTYPE).HasColumnName("CCTYPE");
            this.Property(t => t.CCEXPDATE).HasColumnName("CCEXPDATE");
            this.Property(t => t.CASHACCT).HasColumnName("CASHACCT");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.CUSTID).HasColumnName("CUSTID");
            this.Property(t => t.PAYDATE).HasColumnName("PAYDATE");
            this.Property(t => t.STATUS).HasColumnName("STATUS");
            this.Property(t => t.DOC_REF).HasColumnName("DOC_REF");
            this.Property(t => t.RegisterID).HasColumnName("RegisterID");
            this.Property(t => t.Posted).HasColumnName("Posted");
            this.Property(t => t.SiteID).HasColumnName("SiteID");
            this.Property(t => t.StoreID).HasColumnName("StoreID");
            this.Property(t => t.timestmp).HasColumnName("timestmp");
            this.Property(t => t.Closedout).HasColumnName("Closedout");
            this.Property(t => t.salesman).HasColumnName("salesman");
            this.Property(t => t.vglbatch).HasColumnName("vglbatch");
            this.Property(t => t.vendid).HasColumnName("vendid");
            this.Property(t => t.origin).HasColumnName("origin");
            this.Property(t => t.ipid).HasColumnName("ipid");
            this.Property(t => t.CCNAME).HasColumnName("CCNAME");
            this.Property(t => t.OEID).HasColumnName("OEID");
            this.Property(t => t.PVRV).HasColumnName("PVRV");
            this.Property(t => t.Closed).HasColumnName("Closed");
            this.Property(t => t.Note1).HasColumnName("Note1");
            this.Property(t => t.Note2).HasColumnName("Note2");
            this.Property(t => t.PaId).HasColumnName("PaId");
            this.Property(t => t.hasdetailed).HasColumnName("hasdetailed");
            this.Property(t => t.DueDate).HasColumnName("DueDate");
            this.Property(t => t.Userid).HasColumnName("Userid");
            this.Property(t => t.cstctrid).HasColumnName("cstctrid");
            this.Property(t => t.DBCRACCT).HasColumnName("DBCRACCT");
            this.Property(t => t.TrtPlan).HasColumnName("TrtPlan");
            this.Property(t => t.RateB1).HasColumnName("RateB1");
            this.Property(t => t.RateB2).HasColumnName("RateB2");
            this.Property(t => t.Base1Value).HasColumnName("Base1Value");
            this.Property(t => t.Base2Value).HasColumnName("Base2Value");
            this.Property(t => t.DiscountAmount).HasColumnName("DiscountAmount");
            this.Property(t => t.DiscountPerc).HasColumnName("DiscountPerc");
            this.Property(t => t.DiscountType).HasColumnName("DiscountType");
            this.Property(t => t.OldPVRV).HasColumnName("OldPVRV");
            this.Property(t => t.PSP_Physician).HasColumnName("PSP_Physician");
            this.Property(t => t.PSP_VoucherPrefix).HasColumnName("PSP_VoucherPrefix");

            // Relationships
            this.HasRequired(t => t.Acct)
                .WithMany(t => t.PSPayments)
                .HasForeignKey(d => d.CASHACCT);
            this.HasRequired(t => t.currency1)
                .WithMany(t => t.PSPayments)
                .HasForeignKey(d => d.CURRENCY);
            this.HasOptional(t => t.Cust)
                .WithMany(t => t.PSPayments)
                .HasForeignKey(d => d.CUSTID);
            this.HasOptional(t => t.P)
                .WithMany(t => t.PSPayments)
                .HasForeignKey(d => d.PSID);
            this.HasRequired(t => t.Register)
                .WithMany(t => t.PSPayments)
                .HasForeignKey(d => d.RegisterID);
            this.HasRequired(t => t.Store)
                .WithMany(t => t.PSPayments)
                .HasForeignKey(d => d.StoreID);

        }
    }
}
